package com.pri.chat.activity;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.google.gson.Gson;
import com.netease.nim.uikit.net.SharedHelper;
import com.netease.nim.uikit.net.StatusBarUtil;
import com.netease.nim.uikit.net.entity.BaseBean;
import com.netease.nim.uikit.net.entity.DTBean;
import com.netease.nim.uikit.net.entity.MessageBean;
import com.netease.nim.uikit.net.rxjava.HttpMethods;
import com.netease.nim.uikit.net.subscribers.ProgressSubscriber;
import com.netease.nim.uikit.net.subscribers.SubscriberOnNextListener;
import com.pri.chat.MainActivity;
import com.pri.chat.R;
import com.pri.chat.activity.vedio.Utility;
import com.pri.chat.activity.vedio.widget.DoubleLikeView;
import com.pri.chat.activity.vedio.widget.FullWindowVideoView;
import com.pri.chat.activity.vedio.widget.LikeView;
import com.pri.chat.activity.vedio.widget.NetWorkUtil;
import com.pri.chat.activity.vedio.widget.ProgressView;
import com.pri.chat.activity.vedio.widget.SampleCoverVideo;
import com.pri.chat.adapter.DialogCommentAdapter;
import com.pri.chat.base.BaseActivity;
import com.pri.chat.dialog.DialogUtil;
import com.pri.chat.model.EvaListModel;
import com.pri.chat.model.GzModel;
import com.pri.chat.model.MessageModel;
import com.pri.chat.model.ZanModel;
import com.pri.chat.utils.Des3Util;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.vondear.rxtool.RxActivityTool;
import com.vondear.rxtool.view.RxToast;
import com.vondear.rxui.view.dialog.RxDialogSureCancel;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.OnClick;
import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * 单个视频播放
 */
public class VedioMsgActivity extends BaseActivity implements Handler.Callback {
    //返回
    @BindView(R.id.iv_back1)
    ImageView iv_back1;
    //头像
    @BindView(R.id.author_header)
    ImageView author_header;
    //作者
    @BindView(R.id.author_name)
    TextView author_name;
    //标题
    @BindView(R.id.item_title)
    TextView item_title;
    //视频
    @BindView(R.id.video_view)
    SampleCoverVideo videoView;
    //播放图标
    @BindView(R.id.img_play)
    ImageView imgPlay;
    //双击喜欢
    @BindView(R.id.like)
    DoubleLikeView like;
    //喜欢
    @BindView(R.id.lv_icon)
    LikeView likeView;
    //喜欢数量
    @BindView(R.id.give_a_like_num)
    TextView give_a_like_num;
    //评论图标
    @BindView(R.id.plImage)
    ImageView plImage;
    //评论数量
    @BindView(R.id.pl_num)
    TextView pl_num;
    //分享图标
    @BindView(R.id.shareImg)
    ImageView shareImg;
    //分享文字
    @BindView(R.id.shareTv)
    TextView shareTv;
    @BindView(R.id.gzTv)
    TextView gzTv;
    @BindView(R.id.zanImg)
    ImageView zanImg;




    private DTBean dtBean;
    private String id;
    private int actual_width;
    private int actual_height;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_vedio_msg_layout;
    }

    @Override
    protected void initView() {
        StatusBarUtil.setDarkMode(this);
        //不锁屏幕
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        //透明导航栏
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        id = getIntent().getExtras().getString("id");
        setTitle("");
        if (actual_width <= 0) {
            actual_width = Utility.getsW((Activity) mContext);
        }
        if (actual_height <= 0) {
            actual_height = Utility.getsH((Activity) mContext);
        }
        mHandler = new Handler(this);
        initCommentDialog();
    }

    private void initListener() {
        mSrlComment.setOnRefreshListener(refreshlayout -> {
            refreshlayout.finishRefresh(1500);
            refreshCommentList(false);
        });
        mSrlComment.setOnLoadmoreListener(refreshlayout -> {
            refreshlayout.finishLoadmore(1500);
            comment_page++;
            httpGetComment(false);
        });
        mTvSendMessage.setOnClickListener(view -> {
            if (mEtInput.getText().toString().isEmpty()) {
                RxToast.normal(mEtInput.getHint().toString());
                return;
            }
            httpSendMessage();
        });
        mIvClose.setOnClickListener(view -> {
            mCommentDialog.dismiss();
        });

        zanImg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                zanImg.setVisibility(View.GONE);
                likeView.setVisibility(View.VISIBLE);
                httpLike();
            }
        });

    }

    private void httpSendMessage() {
        HideSoftInput(ll_huifu.getWindowToken());
        SubscriberOnNextListener<BaseBean<List<MessageBean>>> onNextListener = baseBean -> {
            RxToast.normal("评论成功");
            mEtInput.setText("");
            int plNum = Integer.parseInt(dtBean.getPlNum());
            dtBean.setPlNum((plNum + 1) + "");
            pl_num.setText(dtBean.getPlNum());
            refreshCommentList(false);
            sendBroadcastToMain(0);
        };
        Gson gson = new Gson();
        MessageModel circleEnity = new MessageModel();
        circleEnity.setType(1);
        circleEnity.setObjId(dtBean.getId());
        circleEnity.setMemberId(SharedHelper.readId(mContext));
        circleEnity.setContent(mEtInput.getText().toString());
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;charset=utf-8"), Des3Util.getJiaMi(circleEnity));
        HttpMethods.getInstance().savePingLun(new ProgressSubscriber<>(onNextListener, mContext, false), requestBody);
    }

    // 隐藏软键盘
    private void HideSoftInput(IBinder token) {
        if (token != null) {
            InputMethodManager manager = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
            manager.hideSoftInputFromWindow(token,
                    InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }

    Dialog mCommentDialog;
    private SmartRefreshLayout mSrlComment;
    private EditText mEtInput;
    private TextView mTvSendMessage;
    private RecyclerView mRvComment;
    private ImageView mIvClose, mIvNone;
    private LinearLayout ll_huifu;

    private void initCommentDialog() {
        mCommentDialog = new Dialog(mContext, R.style.Theme_Light_Dialog);
        View dialogView = LayoutInflater.from(mContext).inflate(R.layout.dialog_comment, null);
        mSrlComment = dialogView.findViewById(R.id.srl_comment);
        mRvComment = dialogView.findViewById(R.id.rec_comment);
        mIvClose = dialogView.findViewById(R.id.iv_close);
        mIvNone = dialogView.findViewById(R.id.iv_none);
        mTvSendMessage = dialogView.findViewById(R.id.tv_send_message);
        mEtInput = dialogView.findViewById(R.id.et_input);
        ll_huifu = dialogView.findViewById(R.id.ll_huifu);
        ll_huifu.setVisibility(View.VISIBLE);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
        mRvComment.setLayoutManager(linearLayoutManager);
        mRvComment.setNestedScrollingEnabled(false);
        mCommentAdapter = new DialogCommentAdapter(R.layout.item_message, mCommentList);
        mRvComment.setAdapter(mCommentAdapter);
        //获得dialog的window窗口
        Window window = mCommentDialog.getWindow();
        WindowManager wm = getWindowManager();
        //设置dialog在屏幕底部
        window.setGravity(Gravity.BOTTOM);
        //设置dialog弹出时的动画效果，从屏幕底部向上弹出

        window.setWindowAnimations(R.style.dialogStyle);
        window.getDecorView().setPadding(0, 0, 0, 0);
        //获得window窗口的属性
        WindowManager.LayoutParams lp = window.getAttributes();
        //设置窗口宽度为充满全屏
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        //设置窗口高度为包裹内容
        lp.height = 1200;
        //将设置好的属性set回去
        window.setAttributes(lp);
        //将自定义布局加载到dialog上
        mCommentDialog.setContentView(dialogView);

        initListener();
        mCommentAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                switch (view.getId()) {
                    case R.id.iv_logo:
                        if (mCommentList.get(position).getMemberId().equals(SharedHelper.readId(mContext))) {
                            RxActivityTool.skipActivity(mContext, PeopleMsgActivity.class);
                        } else {
                            Bundle bundle = new Bundle();
                            bundle.putString("id", mCommentList.get(position).getMemberId());
                            RxActivityTool.skipActivity(mContext, OtherPeopleMsgActivity.class, bundle);
                        }
                        break;
                }
            }
        });

        mCommentAdapter.setOnItemLongClickListener(new BaseQuickAdapter.OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(BaseQuickAdapter adapter, View view, int position) {
                if (SharedHelper.readId(mContext).equals(dtBean.getMemberId()) || SharedHelper.readId(mContext).equals(mCommentList.get(position).getMemberId())) {
                    //弹出删除提示；
                    initDialog("确定删除该评论？", position);
                }
                return false;
            }
        });
    }

    private void initDialog(String content, int pos) {
        RxDialogSureCancel rxDialogEditSureCancel = new RxDialogSureCancel(mContext);
        rxDialogEditSureCancel.getLogoView().setVisibility(View.GONE);
        rxDialogEditSureCancel.getTitleView().setTextSize(18);
        rxDialogEditSureCancel.getTitleView().setTextColor(Color.BLACK);
        rxDialogEditSureCancel.setTitle("提示");
        rxDialogEditSureCancel.setContent(content);
        rxDialogEditSureCancel.setCancelListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                rxDialogEditSureCancel.dismiss();
            }
        });
        rxDialogEditSureCancel.setSureListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                rxDialogEditSureCancel.dismiss();
                delPingLun(mCommentList.get(pos).getId(), pos);
            }
        });
        rxDialogEditSureCancel.show();
    }

    /**
     * 删除评论
     */
    private void delPingLun(String pingLunId, int pos) {
        SubscriberOnNextListener<BaseBean<List<BaseBean>>> onNextListener = baseBean -> {
            RxToast.normal(baseBean.getMsg());
            if (baseBean.isSuccess()) {
                int plNum = Integer.parseInt(dtBean.getPlNum());
                dtBean.setPlNum((plNum - 1) + "");
                pl_num.setText(dtBean.getPlNum());
                refreshCommentList(false);
                sendBroadcastToMain(0);
            }
        };

        Map<String, Object> params = new HashMap<>();
        params.put("pingLunId", pingLunId);
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;charset=utf-8"), Des3Util.getJiaMi(params));
        HttpMethods.getInstance().delPingLun(new ProgressSubscriber<>(onNextListener, this, true), requestBody);
    }

    @Override
    public boolean handleMessage(Message msg) {
        if (null != msg && START_PROGRESS_ANIMATION == msg.what) {
            if (null == videoView) {
                return false;
            }
        }
        return true;
    }

    @Override
    protected void initData() {
        SubscriberOnNextListener<BaseBean<DTBean>> onNextListener = baseBean -> {
            if (baseBean.isSuccess()) {
                dtBean = baseBean.getData();
                playVideo();
            }
        };

        Map<String, Object> params = new HashMap<>();
        params.put("memberId", SharedHelper.readId(mContext));
        params.put("otherMemberId", id);
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;charset=utf-8"), Des3Util.getJiaMi(params));
        HttpMethods.getInstance().getDongTaiById(new ProgressSubscriber<>(onNextListener, this, false), requestBody);
    }

    private void playVideo() {
        if (dtBean.getSfdz() == 1) {
            zanImg.setVisibility(View.VISIBLE);
            likeView.setVisibility(View.INVISIBLE);
            likeView.setChecked(true);
//            likeView.setCheckedIcon(mContext.getResources().getDrawable(R.drawable.give_like));
//            likeView.setDefaultIcon(mContext.getResources().getDrawable(R.drawable.give_like));
        }
        give_a_like_num.setText(dtBean.getZanNum() + "");
        item_title.setText(dtBean.getContent());
        author_name.setText(dtBean.getMemberName());
        pl_num.setText(dtBean.getPlNum());
        if(dtBean.getSfgz() == 1){
            gzTv.setText("已关注");
            gzTv.setBackgroundResource(R.drawable.btn_gray_20_shape);
            gzTv.setVisibility(View.VISIBLE);
        }else{
            gzTv.setText("关注");
            gzTv.setBackgroundResource(R.drawable.btn_orange_shape);
            gzTv.setVisibility(View.GONE);
        }
        shareTv.setText("分享");
        Glide.with(mContext)
                .asDrawable()
                .load(dtBean.getHeadPic())
                .apply(RequestOptions.bitmapTransform(new CircleCrop()))
                .into(author_header);
        author_header.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Bundle bundle = new Bundle();
                bundle.putString("id", dtBean.getMemberId());
                RxActivityTool.skipActivity(mContext, OtherPeopleMsgActivity.class, bundle);
            }
        });


        if (actual_width <= 0){
            actual_width = Utility.getsW(activity);
        }
        if(actual_height <= 0){
            actual_height = Utility.getsH(activity);
        }
        int image_width = dtBean.getWidth();
        int image_height = dtBean.getHeight();
        double wScale = actual_width*1.0 / image_width;
        double hScale = actual_height*1.0 / image_height;
        double scale = wScale < image_height?wScale:hScale;
        int iamgHeight = (int)(scale*image_height);
        int iamgWidth = (int)(scale*image_width);

        videoView.loadCoverImage(dtBean.getVideoPath()+"?vframe/jpg/offset/0",R.drawable.shape_black,iamgWidth,iamgHeight);
        videoView.setUpLazy(dtBean.getVideoPath(), true, null, null, "这是title");
        //增加title
        videoView.getTitleTextView().setVisibility(View.GONE);
        //设置返回键
        videoView.getBackButton().setVisibility(View.GONE);
        //设置全屏按键功能
        videoView.getFullscreenButton().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                videoView.startWindowFullscreen(mContext, false, true);
            }
        });
        //防止错位设置
        videoView.setPlayTag("TAG");
        videoView.setLockLand(true);
        videoView.setPlayPosition(0);
        //是否根据视频尺寸，自动选择竖屏全屏或者横屏全屏，这个标志为和 setLockLand 冲突，需要和 orientationUtils 使用
        videoView.setAutoFullWithSize(false);
        //音频焦点冲突时是否释放
        videoView.setReleaseWhenLossAudio(false);
        //全屏动画
        videoView.setShowFullAnimation(true);
        //小屏时不触摸滑动
        videoView.setIsTouchWiget(false);
        videoView.requestFocus();
        doPlay();
        setListener();
    }

    private GestureDetector mDetector;
    private long lastDubleTime;
    private int isPrepared;
    private boolean error;
    private boolean hasVideoUri, isBuffer;
    private boolean doubleClickWindow;

    private void setListener() {
        mDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
            @Override
            public boolean onDown(MotionEvent e) {
                return true;
            }

            @Override
            public boolean onSingleTapUp(MotionEvent e) {
                return false;
            }

            @Override
            public boolean onSingleTapConfirmed(MotionEvent e) {
                //连续双击最后的单数，google的GestureDetector把它归类为单击，我认为不应该归类为单击的，在这里将它归属于双击
                if (System.currentTimeMillis() - lastDubleTime <= 600) {
                    onDoubleTap(e);
                    return false;
                }
                lastDubleTime = 0;
                lastDubleTime = 0;
                if (videoView.getGSYVideoManager().isPlaying()) {
                    imgPlay.setVisibility(View.VISIBLE);
                    GSYVideoManager.onPause();
                } else {
                    imgPlay.setVisibility(View.GONE);
                    GSYVideoManager.onResume();
                }
                return true;
            }


            @Override
            public boolean onDoubleTap(MotionEvent e) {
                lastDubleTime = System.currentTimeMillis();
                doubleClickWindow = true;
                like.startAnimator(e);
                likeView.performClick();
                return true;
            }
        });

        like.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return mDetector.onTouchEvent(event);
            }
        });
    }

    private void doPlay() {
        error = false;
        hasVideoUri = false;
        //在无线网下自己播放
        if (NetWorkUtil.getAPNType(this) == ConnectivityManager.TYPE_WIFI) {
            startVideoPlay();
        } else {
            startVideoPlay();
        }
    }

    private final int START_PROGRESS_ANIMATION = 8080;
    private Handler mHandler;
    private String pathDirs = Environment.getExternalStorageDirectory() + "/com.pri.chat/cache/video/";

    private void startVideoPlay() {
        if (null == videoView) return;
        videoView.startPlayLogic();
    }


    @OnClick({R.id.iv_back1, R.id.plImage, R.id.lv_icon, R.id.shareImg,R.id.gzTv})
    public void onViewClicked(View v) {
        if (v.getId() == R.id.iv_back1) {
            //返回
            finish();
        } else if (v.getId() == R.id.shareImg) {
            //点击分享
            initShareDialog(dtBean.getVideoPath() + "?vframe/jpg/offset/0");
        } else if (v.getId() == R.id.plImage) {
            //点击评论
            refreshCommentList(true);
        } else if (v.getId() == R.id.lv_icon) {
            //点赞
            //双击只能点赞，不能取消点赞
            if ((doubleClickWindow && likeView.isChecked()) || (doubleClickWindow && dtBean.getSfdz() == 1) && !likeView.isChecked()) {
                doubleClickWindow = false;
                return;
            }
            doubleClickWindow = false;
            httpLike();
        } else if(v.getId() == R.id.gzTv){
            httpGz();
        }
    }

    private void httpGz() {
        SubscriberOnNextListener<BaseBean> onNextListener = baseBean -> {
            if(baseBean.isSuccess()){
                if(dtBean.getSfgz() == 0){
                    RxToast.normal("关注成功！");
                    dtBean.setSfgz(1);
                    gzTv.setText("已关注");
                    gzTv.setBackgroundResource(R.drawable.btn_gray_20_shape);
                    gzTv.setVisibility(View.GONE);
                }else{
                    RxToast.normal("取消关注成功！");
                    dtBean.setSfgz(0);
                    gzTv.setText("关注");
                    gzTv.setBackgroundResource(R.drawable.btn_orange_shape);
                    gzTv.setVisibility(View.VISIBLE);
                }
                sendBroadcastToMain(0);
            }
        };
        GzModel userModel = new GzModel();
        userModel.setGzrId(SharedHelper.readId(this));
        userModel.setBgzId(dtBean.getMemberId());
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;charset=utf-8"), Des3Util.getJiaMi(userModel));
        HttpMethods.getInstance().saveGuanZhu(new ProgressSubscriber<>(onNextListener, this, true), requestBody);
    }


    private void httpLike() {
        SubscriberOnNextListener<BaseBean> onNextListener = baseBean -> {
            if (baseBean.isSuccess()) {
                //之前就已经点过赞的，再点就取消
                if (dtBean.getSfdz() == 1 && !likeView.isChecked()) {
                    likeView.setChecked(false);
                    likeView.setDefaultIcon(getResources().getDrawable(R.drawable.not_thumb_up));
                } else {
                    likeView.toggle();
                }

                dtBean.setSfdz(dtBean.getSfdz() == 1 ? 0 : 1);
                int zanNum = dtBean.getZanNum();
                if (likeView.isChecked()) {
                    dtBean.setZanNum(zanNum + 1);
                } else {
                    dtBean.setZanNum(zanNum - 1);
                }

                give_a_like_num.setText(dtBean.getZanNum() + "");

                sendBroadcastToMain(0);
            }
        };
        ZanModel zanModel = new ZanModel();
        zanModel.setBdzId(dtBean.getId());
        zanModel.setDzrId(SharedHelper.readId(mContext));
        zanModel.setType(1);
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;charset=utf-8"), Des3Util.getJiaMi(zanModel));
        HttpMethods.getInstance().saveDianZan(new ProgressSubscriber<>(onNextListener, mContext, true), requestBody);
    }

    public void sendBroadcastToMain(int type) {
        Intent intent = new Intent();
        Bundle bundle = new Bundle();
        if (type == 0) {
            intent.setAction(MainActivity.UPDATE_VEDIO);
        } else if (type == 1) {
            intent.setAction(MainActivity.DELETE_VEDIO);
        }
        bundle.putParcelable("dtObj", dtBean);
        intent.putExtras(bundle);
        sendBroadcast(intent);
    }


    private Dialog mShareDialog;

    private void initShareDialog(String path) {
        String memberId = SharedHelper.readId(mContext);
        String listMemberId = dtBean.getMemberId();
        int type = 1;
        if (listMemberId.equals(memberId)) {
            type = 2;
        }
        mShareDialog = DialogUtil.getInstance().showShareDialog(activity, type);
        DialogUtil.getInstance().setOnShareClickListener(new DialogUtil.OnShareClickListener() {
            @Override
            public void qqOnClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putString("id", dtBean.getId());
                bundle.putString("image", path);
                bundle.putString("title", dtBean.getMemberName());
                bundle.putString("content", dtBean.getContent());
                bundle.putInt("type", 2);
                RxActivityTool.skipActivity(mContext, ShareMemberActivity.class, bundle);
                mShareDialog.dismiss();
            }

            @Override
            public void circleOnClick(View v) {
                mShareDialog.dismiss();
                DialogUtil.getInstance().shareWechatMoments(path,HttpMethods.SHARE_TITLE,dtBean.getContent(),HttpMethods.SHARE_URL);
            }

            @Override
            public void qZoneOnClick(View v) {
                mShareDialog.dismiss();
                //删除操作
                deleteDongTai();
            }

            @Override
            public void weixinOnClick(View v) {
                mShareDialog.dismiss();
                DialogUtil.getInstance().shareWechatMoments(path,HttpMethods.SHARE_TITLE,dtBean.getContent(),HttpMethods.SHARE_URL);
            }
            @Override
            public void jubaoOnClick(View v) {
                mShareDialog.dismiss();
                Bundle bundle = new Bundle();
                bundle.putString("id",dtBean.getId());
                bundle.putString("type","1");
                RxActivityTool.skipActivity(mContext, ReleaseJuBaoAcctivity.class,bundle);

            }
        });
        mShareDialog.show();
    }

    private void deleteDongTai() {
        SubscriberOnNextListener<BaseBean> onNextListener = baseBean -> {
            if (baseBean.isSuccess()) {
                RxToast.normal("删除成功！");
                sendBroadcastToMain(1);
                finish();
            }
        };

        Map<String, Object> params = new HashMap<>();
        params.put("id", dtBean.getId());
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;charset=utf-8"), Des3Util.getJiaMi(params));
        HttpMethods.getInstance().deleteDongTai(new ProgressSubscriber<>(onNextListener, mContext, false), requestBody);
    }

    private int comment_page = 1;
    private List<MessageBean> mCommentList = new ArrayList<>();
    private DialogCommentAdapter mCommentAdapter;

    private void refreshCommentList(boolean s) {
        comment_page = 1;
        mCommentList.clear();
        mCommentAdapter.notifyDataSetChanged();
        httpGetComment(s);
    }

    private void httpGetComment(boolean isShowComment) {
        SubscriberOnNextListener<BaseBean<List<MessageBean>>> onNextListener = baseBean -> {
            if (isShowComment) {
                mCommentDialog.show();
            }
            if (baseBean.getData().isEmpty() && comment_page == 1) {
                mIvNone.setVisibility(View.VISIBLE);
                mCommentAdapter.notifyDataSetChanged();
            } else {
                mIvNone.setVisibility(View.INVISIBLE);
                mCommentList.addAll(baseBean.getData());
                mCommentAdapter.notifyDataSetChanged();
            }
        };

        EvaListModel evaListModel = new EvaListModel();
        evaListModel.setPageIndex(comment_page);
        evaListModel.setObjId(dtBean.getId());
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;charset=utf-8"), Des3Util.getJiaMi(evaListModel));
        HttpMethods.getInstance().listPingLun(new ProgressSubscriber<>(onNextListener, mContext, false), requestBody);
    }

    @Override
    protected void onStop() {
        super.onStop();
    }

    @Override
    protected void onPause() {
        super.onPause();
        GSYVideoManager.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        GSYVideoManager.onResume();
    }

    @Override
    protected void onDestroy() {
        if (null != videoView){
            videoView.release();
        }
        mHandler.removeCallbacksAndMessages(null);
        super.onDestroy();
    }
}

